//
//  AxisViewController.m
//  VICKY ZONE
//
//  Created by sunx on 15/3/21.
//  Copyright (c) 2015年 sunx. All rights reserved.
//
#define SERVER @"http://127.0.0.1/01/controller/blogController.php"

#import "AxisViewController.h"
#import "NSURLSession+KKAddition.h"
#import "ImageLoader.h"

@interface AxisViewController ()

@end

@implementation AxisViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}
- (void)loadList {
    [NSURLSession GET:SERVER pararms:@{@"user":@"vicky",@"type":@"axis"} completed:^(NSData *data) {
        [self xmlParse:data];
    } failed:^(NSError *error) {
        if(error){
            NSLog(@"%@",error);
        }
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)xmlParse:(NSData *)xmlData {
    NSXMLParser *m_parser = [[NSXMLParser alloc] initWithData:xmlData];
    //设置该类本身为代理类，即该类在声明时要实现NSXMLParserDelegate委托协议
    [m_parser setDelegate:self];  //设置代理为本地
    
    BOOL flag = [m_parser parse]; //开始解析
    if(flag) {
        NSLog(@"获取指定路径的xml文件成功");
    }else{
        NSLog(@"获取指定路径的xml文件失败");
    }
}

#pragma mark-NSXMLParserDelegate
/**
 *开始解析文档时调用
 */
-(void)parserDidStartDocument:(NSXMLParser *)parser
{
    NSLog(@"开始解析文档");
}
/**
 *结束解析文档时调用（解析完毕）
 */
-(void)parserDidEndDocument:(NSXMLParser *)parser {
    NSLog(@"结束解析文档");
    //[self performSelectorOnMainThread:@selector(updateMessage) withObject:self waitUntilDone:YES];
}


/**
 *解析到一个元素的开头时调用
 */
bool isMood = NO;
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    NSLog(@"%@",namespaceURI);
}
/**
 *解析到一个元素的结尾时调用
 */
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    
    
    NSLog(@"解析到一个元素的结尾---%@",elementName);
}
//step 3:获取首尾节点间内容
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    
    NSLog(@"%@",string);
}


@end
